import 'package:clock_notification/model/base_widget.dart';
import 'package:clock_notification/pages/home_page.dart';
import 'package:clock_notification/pages/location.dart';
import 'package:clock_notification/pages/map.dart';
import 'package:clock_notification/pages/message_page.dart';
import 'package:clock_notification/pages/mine_page.dart';
import 'package:flutter/material.dart';

import '../pages/applied/free_applied.dart';
import 'car.dart';
import 'list_view_demo.dart';
import 'location_widget.dart';

class Home extends StatefulWidget {
  const Home({super.key});

  final Color _themColor = const Color.fromRGBO(220, 220, 220, 0);

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int _currentIndex = 0;
  List<String> currentTitles = ["首页", "消息", "我的", "定位", "协议签署"];
  List<Widget> pages = [
    HomePage(),
    MessagePage(),
    MinePage(),
    const LocationApp(),
    const FreeAppliedPage()
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        elevation: 10,
        child: const Icon(Icons.add),
        onPressed: () {

        },
      ),
      bottomNavigationBar: BottomNavigationBar(
        // 超过3个图标会显示
        type: BottomNavigationBarType.fixed,
        fixedColor: Colors.blue,
        // 当前坐标
        currentIndex: _currentIndex,
        onTap: (index) {
          // print(index);
          setState(() {
            _currentIndex = index;
          });
        },

        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
          BottomNavigationBarItem(icon: Icon(Icons.message), label: "消息"),
          BottomNavigationBarItem(icon: Icon(Icons.person), label: "我的"),
          BottomNavigationBarItem(icon: Icon(Icons.location_on), label: "定位"),
          BottomNavigationBarItem(icon: Icon(Icons.picture_as_pdf), label: "pdf"),
        ],
      ),
      appBar: AppBar(
        backgroundColor: widget._themColor,
        title: Container(
          // color: Colors.lightGreen,
          alignment: Alignment.center,
          child: Stack(
            alignment: Alignment.center,
            children: [
              Text(currentTitles[_currentIndex]),
              GestureDetector(
                onTap: () {
                  // print("222");
                  showModalBottomSheet(
                      context: context,
                      builder: (context) {
                        return Container(
                          padding: const EdgeInsets.only(bottom: 20),
                          child: const Column(
                            children: [
                              ListTile(
                                leading: Icon(Icons.share_outlined),
                                title: Text("分享"),
                                tileColor: Colors.lightGreen,
                              )
                            ],
                          ),
                        );
                      });
                },
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    const Icon(Icons.share_outlined),
                    RichText(
                      text: const TextSpan(
                        text: "ID分享",
                        style: TextStyle(color: Colors.blue, fontSize: 20),
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        ),
        elevation: 0.0,
      ),
      // body: MyApp(),
      body: pages[_currentIndex],
      // body: const LocationApp(),
    );
  }
}
